package org.example.controller;

import com.nowoe.core.annotation.Autowired;
import com.nowoe.mvc.annotation.Controller;
import com.nowoe.mvc.annotation.RequestMapping;
import com.nowoe.mvc.annotation.RequestParam;
import org.example.entity.User;
import org.example.service.UserService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 倚栏听风 2023/9/20 21:05
 */
@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getUser")
    public String getUser(HttpServletRequest request, HttpServletResponse response, @RequestParam("id") Integer id) {
        User user = userService.getUser(id);
        request.setAttribute("username", user.getUsername());
        return "user.jsp";
    }
}
